package com.example.user.event;

import com.example.user.entity.User;
import com.example.user.enumerate.OperateTypeEnum;
import lombok.Builder;
import org.springframework.context.ApplicationEvent;

/**
 * 自定义事件：用户通知事件
 *
 * @author vanson
 */
@Builder
public class UserNotifyEvent extends ApplicationEvent {
    private User user;
    private OperateTypeEnum operateTypeEnum;

    public OperateTypeEnum getOperateTypeEnum() {
        return operateTypeEnum;
    }

    public User getUser() {
        return user;
    }

    public UserNotifyEvent(Object source) {
        super(source);
        this.user = (User) source;
    }

    public UserNotifyEvent(Object source, OperateTypeEnum operateTypeEnum) {
        super(source);
        this.user = (User) source;
        this.operateTypeEnum = operateTypeEnum;
    }

    @Override
    public String toString() {
        return this.user + "," + this.operateTypeEnum == null ? "" : this.operateTypeEnum.name();
    }
}
